*This is the code for replicating the analyses presented in 'Pleasing the Buyer: Human rights experts from exporting countries and praise of importing countries', by Sara Kahn-Nisser

*Analysis run using Stata17

* Change directory to where the do-file is located
cd "`c(pwd)'"

* Open the dataset 
use "Replication data Kahn-Nisser Pleasing the buyer.dta", clear

*Generate table one
sum positive_0 log_exports atop_max_defense log_pop_02 log_gdppc_02  FDI2GDP_02 vdem_lib_dem_index_01 vdem_lib_dem_index_02 fariss_46to19_01  fariss_46to19_02  serfscore_01 serfscore_02 v2clsocgrp_ord_01 v2clsocgrp_ord_02 log_aid agree  if sample_identifier==1

*Model One
xtreg log_positive ll(log_exports atop_max_defense   log_pop_02 log_gdppc_02  FDI2GDP_02)   , robust

*Model Two
xtreg log_positive ll( log_exports atop_max_defense log_pop_02 log_gdppc_02  FDI2GDP_02 vdem_lib_dem_index_01 vdem_lib_dem_index_02 fariss_46to19_01  fariss_46to19_02  serfscore_01 serfscore_02 v2clsocgrp_ord_01 v2clsocgrp_ord_02  )  i.year , robust fe

*Model Three
xtreg log_positive ll( log_exports atop_max_defense log_pop_02 log_gdppc_02  FDI2GDP_02 vdem_lib_dem_index_01 vdem_lib_dem_index_02 fariss_46to19_01  fariss_46to19_02  serfscore_01 serfscore_02 v2clsocgrp_ord_01 v2clsocgrp_ord_02 TradeofGDP_01 TradeofGDP_02  )  i.year , robust fe

*Model Four
xtreg log_positive ll( log_exports atop_max_defense log_pop_02 log_gdppc_02  FDI2GDP_02 vdem_lib_dem_index_01 vdem_lib_dem_index_02 fariss_46to19_01  fariss_46to19_02  serfscore_01 serfscore_02 v2clsocgrp_ord_01 v2clsocgrp_ord_02 agree  )  i.year , robust fe

*Model Five
xtreg log_positive ll( log_exports atop_max_defense log_pop_02 log_gdppc_02  FDI2GDP_02 vdem_lib_dem_index_01 vdem_lib_dem_index_02 fariss_46to19_01  fariss_46to19_02  serfscore_01 serfscore_02 v2clsocgrp_ord_01 v2clsocgrp_ord_02 log_aid )  i.year , robust fe

*Model Six
xtgls log_positive ll(c.log_exports##partner_in_tb  v2clsocgrp_ord_02 i.defense_atop_0 v2clsocgrp_ord_01 serfscore_02 serfscore_01   fariss_46to19_02 fariss_46to19_01 vdem_lib_dem_index_02 vdem_lib_dem_index_01 log_pop_02 log_gdppc_02  FDI2GDP_02 agree log_aid )     b_cerd_rat_02  b_cescr_rat_02  i.dyadtreatydummy i.year

*Marginal effects analysis
margins, at (L2.partner_in_tb=(0 1)l2.log_exports=(5 27)) level(90)

*Generate Figure Three
marginsplot

*Model Seven
reg d.log_positive l.c.dif_log_exports##l.partner_in_tb l.i.defense_atop_0  ld(v2clsocgrp_ord_02 v2clsocgrp_ord_01 serfscore_02 serfscore_01   fariss_46to19_02 fariss_46to19_01 vdem_lib_dem_index_02 vdem_lib_dem_index_01 log_pop_02 log_gdppc_02  FDI2GDP_02 agree log_aid )  l.b_cerd_rat_02  l.b_cescr_rat_02 i.year , robust

*Model Eight
xtgls log_positive ll(c.log_exports##partner_in_tb  v2clsocgrp_ord_02 i.defense_atop_0 v2clsocgrp_ord_01 serfscore_02 serfscore_01   fariss_46to19_02 fariss_46to19_01 vdem_lib_dem_index_02 vdem_lib_dem_index_01 log_pop_02 log_gdppc_02  FDI2GDP_02 agree log_aid negative_0)     b_cerd_rat_02  b_cescr_rat_02  i.dyadtreatydummy i.year ,

*Model Nine
xtgls log_positive ll(c.dyadexpoftot##partner_in_tb  v2clsocgrp_ord_02 i.defense_atop_0 v2clsocgrp_ord_01 serfscore_02 serfscore_01   fariss_46to19_02 fariss_46to19_01 vdem_lib_dem_index_02 vdem_lib_dem_index_01 log_pop_02 log_gdppc_02  FDI2GDP_02 agree log_aid )     b_cerd_rat_02  b_cescr_rat_02  i.dyadtreatydummy i.year

*Model Ten
 xtgls log_positive ll(c.dyadexpofgdp##partner_in_tb  v2clsocgrp_ord_02 i.defense_atop_0 v2clsocgrp_ord_01 serfscore_02 serfscore_01   fariss_46to19_02 fariss_46to19_01 vdem_lib_dem_index_02 vdem_lib_dem_index_01 log_pop_02 log_gdppc_02  FDI2GDP_02 agree log_aid )     b_cerd_rat_02  b_cescr_rat_02  i.dyadtreatydummy i.year 
 
*Model Eleven
xtgls log_positive ll(c.trade_balance##partner_in_tb  v2clsocgrp_ord_02 i.defense_atop_0 v2clsocgrp_ord_01 serfscore_02 serfscore_01   fariss_46to19_02 fariss_46to19_01 vdem_lib_dem_index_02 vdem_lib_dem_index_01 log_pop_02 log_gdppc_02  FDI2GDP_02 agree log_aid )     b_cerd_rat_02  b_cescr_rat_02 i.dyadtreatydummy i.year ,

*Model Tweleve
xtgls log_positive ll(c.log_exports##partner_in_tb##c.sumta_01  v2clsocgrp_ord_02 i.defense_atop_0 v2clsocgrp_ord_01 serfscore_02 serfscore_01   fariss_46to19_02 fariss_46to19_01 vdem_lib_dem_index_02 vdem_lib_dem_index_01 log_pop_02 log_gdppc_02  FDI2GDP_02 agree log_aid )  b_cerd_rat_02  b_cescr_rat_02  i.dyadtreatydummy i.year

*model thirteen
zip positive_0 c.l2_dyadexpofgdp##partner_in_tb l2_atop_max_defense   l2_log_pop_02 l2_log_gdppc_02  l2_FDI2GDP_02  l2_v2clsocgrp_ord_02 l2_v2clsocgrp_ord_01 l2_serfscore_02 l2_serfscore_01   l2_fariss_46to19_02 l2_fariss_46to19_01 l2_vdem_lib_dem_index_02 l2_vdem_lib_dem_index_01 ,inf(l2_anytreaty) vce(robust)

*Model Thirteen
zip positive_0 c.l2_dyadexpofgdp##partner_in_tb l2_atop_max_defense   l2_log_pop_02 l2_log_gdppc_02  l2_FDI2GDP_02  l2_v2clsocgrp_ord_02 l2_v2clsocgrp_ord_01 l2_serfscore_02 l2_serfscore_01   l2_fariss_46to19_02 l2_fariss_46to19_01 l2_vdem_lib_dem_index_02 l2_vdem_lib_dem_index_01 ,inf(l2_anytreaty) vce(robust) 
